﻿using System;
using DBProvider;

namespace HealthCommunity
{
	public partial class CourseChapterDetail : System.Web.UI.Page
	{
		protected void Page_Load(object sender, EventArgs e)
		{
			if(!IsPostBack)
			{
				var theCourse = GetCourse();

				if(theCourse != null)
				{
					this.ltrCourseName.Text = theCourse.CourseName;
					this.Title = theCourse.CourseName;
				}
			}
		}

		private Course GetCourse()
		{
			Course result = null;

			var courseChapterID = CommonHelper.QueryStringInt("coursechapterid");

			if(courseChapterID > 0)
			{
				var courseProvider = new DBProvider.Providers.CourseProvider();

				var theCourseChapter = courseProvider.GetCourseChapter(courseChapterID);

				if(theCourseChapter != null)
				{
					result = courseProvider.GetCourse(theCourseChapter.CourseID.Value);
				}
			}

			return result;
		}
	}
}
